package com.ruoyi.applet.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.applet.mapper.MiniCaseMapper;
import com.ruoyi.applet.domain.MiniCase;
import com.ruoyi.applet.service.IMiniCaseService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 案例Service业务层处理
 *
 * @author liucan
 * @date 2024-03-26
 */
@Transactional
@Service
public class MiniCaseServiceImpl implements IMiniCaseService {
    @Resource
    private MiniCaseMapper miniCaseMapper;

    /**
     * 查询案例
     *
     * @param id 案例主键
     * @return 案例
     */
    @Override
    public MiniCase selectMiniCaseById(Long id) {
        return miniCaseMapper.selectMiniCaseById(id);
    }

    /**
     * 查询案例列表
     *
     * @param miniCase 案例
     * @return 案例
     */
    @Override
    public List<MiniCase> selectMiniCaseList(MiniCase miniCase) {
        return miniCaseMapper.selectMiniCaseList(miniCase);
    }

    /**
     * 新增案例
     *
     * @param miniCase 案例
     * @return 结果
     */
    @Override
    public int insertMiniCase(MiniCase miniCase) {
        miniCase.setCreationBy(SecurityUtils.getUsername());//创建人
        miniCase.setCreationTime(DateUtils.getTime());//创建时间
        return miniCaseMapper.insertMiniCase(miniCase);
    }

    /**
     * 修改案例
     *
     * @param miniCase 案例
     * @return 结果
     */
    @Override
    public int updateMiniCase(MiniCase miniCase) {
        return miniCaseMapper.updateMiniCase(miniCase);
    }

    /**
     * 批量删除案例
     *
     * @param ids 需要删除的案例主键
     * @return 结果
     */
    @Override
    public int deleteMiniCaseByIds(Long[] ids) {
        return miniCaseMapper.deleteMiniCaseByIds(ids);
    }

    /**
     * 删除案例信息
     *
     * @param id 案例主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteMiniCaseById(Long id) {
        return miniCaseMapper.deleteMiniCaseById(id);
    }
}
